<%= error_messages_for :ticket %>
<% form_for :ticket, :url => ticket_path(@ticket), :html => {:method => :put, :onSubmit => "javascript:set_checkboxes();"} do -%>
<table border = "0" width = "100%"><tr><td>
    Type: <%=h @ticket.ticket_template.name %><br />
    <label for="ticket_number">Number:</label> <%= @ticket.number %><br />
    <label for="ticket_name">Name:</label>
	<%= @ticket.name  %><br />
    Created by <%=h @ticket.created_by ? @ticket.created_by.name : "somebody"%><br />
    <% if @ticket.updated_at %>
	Updated by <%=h @ticket.updated_by ? @ticket.updated_by.name : "somebody" %> at <%= @ticket.updated_at  %><br />
    <% end %>
	
	<p><label for="ticket_deadline">Deadline:</label>
	<%= calendar_date_select_tag "ticket[deadline]", @ticket.deadline, {:id => "ticket_deadline", :size => '10', :maxlength => '10' } %></p></td>
        
	<td align = 'right'> 
         <%= submit_tag 'Edit' %> </td></tr></table>
    <%= render :partial => 'fields'-%>
  
<% end %>
<br />
<b>Comments:</b> <br />
<% @ticket.comments.each do |comment| %>
<span class="username"><%=h comment.user ? comment.user.name : "Somebody"-%></span> wrote at <%= comment.created_at -%> <%=  (current_user.admin? || current_user == comment.user)? (link_to "remove", ticket_comment_path(@ticket, comment), :method => :delete, :confirm => "Are you sure?") : ""%>: 
<p class="comment"> <%= comment.value %> </p>
<% end %>

<% form_for :ticket, :url => ticket_comments_path(@ticket)  do%>
   <%= text_area_tag 'comment[value]', nil, :size => "40x2" %>
   <%= submit_tag "Add comment"%>
<% end %>
